<?php 
class database {

    private $fileName;
    private $db_host ; 
    private $db_username;  
    private $db_pass;  
    private $db_name; 
// contructor hnb3tlo name alfile aly feh alusername walpass walserver bto3 aldatbase
    
            function __construct($fileName) {
        if (is_file($fileName)) {
            include $fileName;
        } else {
            die("error: configuration file name is wrong. ");
        }
        //intialize
        $this->db_host=$db_host;
        $this->db_name=$db_name;
        $this->db_pass=$db_pass;
        $this->db_username=$db_username;
        //calling alfunction aly bt3ml coneect 
        $this->connectDB();
        
    }

private function connectDB(){
    // connection to server
    if (!mysql_connect($this->db_host, $this->db_username, $this->db_pass)) {
            throw new Exception("error: not conected to server.");
        }
        //selecting database
        if (!mysql_select_db($this->db_name)) {
            throw new Exception("error: no database selected.");
        }
    }
function close(){
    
    mysql_close();
}
//  mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
//mysql_select_db("$db_name") or die ("no database"); 
}
?>
